package com.tensquare.user.dao;


import com.tensquare.user.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * 数据访问接口
 */

public interface UserDao extends JpaRepository<User,String>, JpaSpecificationExecutor<User> {
    //通过手机号查询用户实体
    public User findByMobile(String mobile);

    //当你被别人喜欢（关注）了的时候增加fanscount
    @Modifying
    @Query(value = "update tb_user set fanscount=fanscount+? where id=?",nativeQuery = true)
    public void updateFansCount(int x,String friendid);

    //当你喜欢别人（关注别人）的时候增加followcount
    @Modifying
    @Query(value = "update tb_user set followcount=followcount+? where id=?",nativeQuery = true)
    public void updateFollowCount(int x,String userid);
}
